package org.hl7.datatypes.r2.basic;

import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.MappedSuperclass;
import javax.validation.constraints.NotNull;
import org.hl7.datatypes.r2.flavors.st.ST_NT;
import org.hl7.datatypes.r2.flavors.st.ST_SIMPLE;
import org.hl7.datatypes.r2.foundation.DSET;
import org.hl7.datatypes.r2.foundation.TYPE;

@Embeddable
@MappedSuperclass
public class ST extends ED {

    @Column(name = "ST_VALUE")
    @NotNull
    private String stValue;

    public ST(String value) {
        this.stValue = value;
    }

    public ST() {
    }

    public ST_NT headCharacter() {
        return new ST_NT(String.valueOf(stValue.charAt(0)));
    }

    public ST_NT tailString() {
        return new ST_NT(String.valueOf(stValue.charAt(stValue.length())));
    }

    @Override
    public TYPE dataType() {
        return super.dataType(); //To change body of generated methods, choose Tools | Templates.
    }
    

    public DSET<ST_NT> translation() {
        //TODO
        return null;
    }

    public ST_SIMPLE literal() {
        return new ST_SIMPLE(stValue);
    }

    public String getStValue() {
        return stValue;
    }

    public void setStValue(String stValue) {
        this.stValue = stValue;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 89 * hash + Objects.hashCode(this.stValue);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final ST other = (ST) obj;
        if (!Objects.equals(this.stValue, other.stValue)) {
            return false;
        }
        return true;
    }
}
